package com.ruoyi.order.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.order.domain.CheServiceName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.order.mapper.CheOrderMapper;
import com.ruoyi.order.domain.CheOrder;
import com.ruoyi.order.service.ICheOrderService;

/**
 * 订单Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@Service
public class CheOrderServiceImpl implements ICheOrderService 
{
    @Autowired
    private CheOrderMapper cheOrderMapper;

    /**
     * 查询订单
     * 
     * @param id 订单主键
     * @return 订单
     */
    @Override
    public CheOrder selectCheOrderById(Long id)
    {
        return cheOrderMapper.selectCheOrderById(id);
    }

    /**
     * 查询订单列表
     * 
     * @param cheOrder 订单
     * @return 订单
     */
    @Override
    public List<CheOrder> selectCheOrderList(CheOrder cheOrder)
    {
        return cheOrderMapper.selectCheOrderList(cheOrder);
    }

    /**
     * 新增订单
     * 
     * @param cheOrder 订单
     * @return 结果
     */
    @Override
    public int insertCheOrder(CheOrder cheOrder)
    {
        cheOrder.setCreateTime(DateUtils.getNowDate());
        return cheOrderMapper.insertCheOrder(cheOrder);
    }

    /**
     * 修改订单
     * 
     * @param cheOrder 订单
     * @return 结果
     */
    @Override
    public int updateCheOrder(CheOrder cheOrder)
    {
        return cheOrderMapper.updateCheOrder(cheOrder);
    }

    /**
     * 批量删除订单
     * 
     * @param ids 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteCheOrderByIds(Long[] ids)
    {
        return cheOrderMapper.deleteCheOrderByIds(ids);
    }

    /**
     * 删除订单信息
     * 
     * @param id 订单主键
     * @return 结果
     */
    @Override
    public int deleteCheOrderById(Long id)
    {
        return cheOrderMapper.deleteCheOrderById(id);
    }

    @Override
    public Map<Object, Object> selectAllByOrderId(Map map) {
        List<Map<Object, Object>> list = cheOrderMapper.findAllByOrderId(map);
        Map<Object,Object> map1 = new HashMap<>();
        map1.put("list",list);
        return map1;
    }

    @Override
    public List<CheServiceName> selectAllByOrderId2(Long id) {
        List<CheServiceName> list = cheOrderMapper.findAllByOrderId2(id);
        return list;
    }


}
